package com.example.myapplication.model;

import com.example.myapplication.base.BaseModel;
import com.example.myapplication.bean.HomesBanner;
import com.example.myapplication.bean.HomesListBean;
import com.example.myapplication.net.ResultCallBack;
import com.example.myapplication.util.HttpUtil;
import com.example.myapplication.util.ResultSubscriber;
import com.example.myapplication.util.RxUtils;

public class HomesModel extends BaseModel {
    public void getHomesData(final ResultCallBack<HomesBanner> callBack) {
        addDisposable(
                HttpUtil.getInstance()
                .getHomesBannerService()
                .getData()
                .compose(RxUtils.<HomesBanner>ttFlowableTransformer())
                .subscribeWith(new ResultSubscriber<HomesBanner>() {
                    @Override
                    public void onNext(HomesBanner homesBanner) {
                        callBack.onSuccess(homesBanner);
                    }
                })
        );
    }

    public void getHomesList(final ResultCallBack<HomesListBean> resultCallBack) {
        addDisposable(
                HttpUtil.getInstance()
                .getHomesListService()
                .getData()
                .compose(RxUtils.<HomesListBean>ttFlowableTransformer())
                .subscribeWith(new ResultSubscriber<HomesListBean>() {
                    @Override
                    public void onNext(HomesListBean homesListBean) {
                        resultCallBack.onSuccess(homesListBean);
                    }
                })
        );
    }
}
